layui.define(['table', 'form'], function (exports) {
    var $ = layui.$
        , form = layui.form
        , table = layui.table
        , setter = layui.setter
        , admin = layui.admin
        , dropdown = layui.dropdown;
    var renderTable;
    var field = '';
    var colsArr;

    var tableTitle;
    var tableField; //表头字段
    var tableSearch = [];//全局搜索条件
    var tableHead;//表头字段


    tableRender();

    function tableRender() {
        colsArr = [
            {field: '', title: '序号', width: 40, type: 'numbers'},
            {field: 'receiverName', title: '收货员名称', align: 'center'},
            {field: 'receiverNumber', title: '收货员编号', align: 'center'},
            {
                field: 'isFree', title: '状态', align: 'center', templet: function (d) {
                    if (d.isFree == 0) {
                        return `<span style="color: #b52c26" class="layui-font-red">忙碌中</span>`
                    } else {
                        return `<span style="color: #00be67" class="layui-font-red">空闲中</span>`
                    }
                }
            },
            {
                title: '状态修改', field: 'dutyFlag', align: 'center', templet: function (d) {
                    if (d.dutyFlag != 0) {
                        return `<div><span style="color: #b52c26">当前状态:离岗|</span><a style="color: #00be67" href="javascript:void(0);" lay-event="work" class="layui-font-blue">点击修改状态为在岗</div>`
                    } else {
                        return `<div><span style="color: #00be67">当前状态:在岗|</span><a style="color: #b52c26" href="javascript:void(0);" lay-event="holiday" class="layui-font-blue">点击修改状态为离岗</div>`
                    }
                }
            }
        ]
        loadTable(colsArr);
    }


    function loadTable() {
        var tableWhere = {};
        tableWhere.headField = field;

        renderTable = table.render({
            elem: '#LAY-reservation-list',
            limit: 15,
            limits: [15, 30, 50],
            cols: [colsArr],
            height: 'full-15',
            page: true, //开启分页
            method: 'post',
            url: '/unite_platform/reservation/receiver/getAllReceiver'
            , text: {
                none: '暂无相关数据'
            }
        });

        // table.on('select(status)', function (data) {
        //     console.log("22222");
        //     console.log(data.value);
        //     console.log(this);
        // });

        //监听行工具事件
        table.on('tool(LAY-reservation-list)', function (obj) {
            //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
            var data = obj.data //获得当前行数据
                , layEvent = obj.event; //获得 lay-event 对应的值

            switch (layEvent) {
                case "holiday":
                    console.log(data)
                    admin.req({
                        url: setter.host + `/reservation/receiver/receiverHoliday`
                        , type: 'post'
                        , header: {"Content-Type": "application/x-www-form-urlencoded"}
                        , data: {
                            "reservationNumber": data.receiverNumber
                        }
                        , done: function (res) {
                            table.reload('LAY-reservation-list');
                            layer.msg(res.msg);
                        }
                    })
                    return
                case "work":
                    console.log(data)
                    admin.req({
                        url: setter.host + `/reservation/receiver/receiverWork`
                        , type: 'post'
                        , header: {"Content-Type": "application/x-www-form-urlencoded"}
                        , data: {
                            "reservationNumber": data.receiverNumber
                        }
                        , done: function (res) {
                            table.reload('LAY-reservation-list');
                            layer.msg(res.msg);
                        }
                    })
                    // $.ajax({
                    //     url: setter.host + `/reservation/receiver/receiverWork`
                    //     , type: "POST"
                    //     , data: JSON.stringify(playload)
                    //     , contentType: "application/json; charset=utf-8"
                    //     , dataType: "json"
                    //     , success: function (res) {
                    //         if (res.code === 0 && res.msg === "重新分配月台成功") {
                    //             table.reload('LAY-reservation-list');
                    //             layer.msg(res.msg);
                    //             layer.close(index);
                    //         }
                    //     }
                    // })
                    return;
                case "confirm":
                    layer.open({
                        type: 2
                        , title: '确认预约'
                        , content: setter.host + '/confirm'
                        , area: ['720px', '590px']
                        , btn: ['确定', '取消']
                        , success: function (editFrame, index) {
                            var iframeWindow = window['layui-layer-iframe' + index]
                                , subBody = editFrame.find('iframe').contents();
                            new Promise(function (resolve, reject) {
                                admin.req({
                                    url: setter.host + `/reservation/supplier/getBoxamount`
                                    , type: 'post'
                                    , header: {"Content-Type": "application/x-www-form-urlencoded"}
                                    , data: {
                                        "reservationNumber": data.reservationNumber
                                    }
                                    , done: function (res) {
                                        if (res.code === 0) {
                                            resolve(res.data)
                                        } else {
                                            layer.msg("获取托盘错误")
                                        }

                                        data.orders.map(item => {
                                            console.log(item)
                                            subBody.find("#orderNumbers").append(`<input type="text" value="${item.orderNumber}"  id="${item.orderNumber}" readonly autocomplete="off" class="layui-input">`)
                                            subBody.find(`#${item.orderNumber}`).val(`${item.orderNumber}`)
                                        })

                                        // data.drivers.map(item=>{
                                        let ind = 0
                                        for (let item of data.drivers) {
                                            ind++
                                            // console.log(item)

                                            subBody.find("#cars").append(`
                                        <label class="layui-form-label">车辆信息：</label>
                                        <input type="hidden" name="carId[]" value="${item.id}" >

                                        <div class="layui-form-item">
                                          <label class="layui-form-label">车型</label>
                                          <div class="layui-input-inline" >
                                            <input type="text"  value="${item.carType}" id="carType" readonly autocomplete="off" class="layui-input">
                                          </div>
                                       </div>
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">车长</label>
                                          <div class="layui-input-inline" >
                                            <input type="text"  value="${item.carLength}" id="carLength" readonly autocomplete="off" class="layui-input">
                                          </div>
                                        </div>
                                    
                                    
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">分配月台</label>
                                          <div class="layui-input-inline" >
                                            <input type="hidden" name="estimatedPlatformNumber"  id="estimatedPlatformNumber" readonly autocomplete="off" class="layui-input">
                                            <select name="confirmPlatformNumber[]" id="platform" lay-verify="required"  >
                                              <option value="请选择" >请选择</option>

                                            </select>
                                          </div>
                                        </div>
                                    
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">分配收货员</label>
                                          <div class="layui-input-inline" >
                                            <input type="hidden" name="estimatedReceiverNumber" id="estimatedReceiverNumber"  autocomplete="off" class="layui-input" >
                                            <select name="confirmReceiverNumber[]" id="receiver" lay-verify="required">
                                              <option value="请选择" >请选择</option>
                                            </select>
                                          </div>
                                        </div>
                                        `)
                                        }

                                    }
                                });
                            }).then((res) => {
                                subBody.find("#id").val(data.id)
                                subBody.find("#driverCount").val(data.drivers.length)
                                subBody.find("#reservationNumber").val(data.reservationNumber)
                                subBody.find("#driverNumber").val(data.driverNumber)
                                subBody.find("#supplierNumber").val(data.supplierNumber)
                                subBody.find("#supplierName").val(data.supplierName)
                                subBody.find("#gdsCount").val(data.gdsCount)
                                subBody.find("#gdsNumber").val(data.gdsNumber)
                                subBody.find("#orderNumber").val(data.orderNumber)
                                subBody.find("#estimatedArrivalTime").val(data.estimatedArrivalTime)
                                subBody.find("#confirmArrivalTime").val(data.estimatedArrivalTime)
                                subBody.find("#confirmOverTime").val(data.confirmOverTime)
                                subBody.find("#trayCount").val(res)
                            })

                        }
                        , yes: function (index, layero) {
                            var iframeWindow = window['layui-layer-iframe' + index]
                                , submitID = 'LAY-menu-edit-submit'
                                , submit = layero.find('iframe').contents().find('#' + submitID);
                            //监听提交
                            iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                                let playload = data.field
                                console.log(playload)
                                admin.req({
                                    url: setter.host + `/reservation/receiveManager/confirmReservation/${playload.reservationNumber}`
                                    , type: 'post'
                                    , dataType: 'json'
                                    , contentType: "application/json; charset=utf-8"
                                    , data: JSON.stringify(playload)
                                    , done: function (res) {
                                        if (res.code === 0 && res.msg === "预约单确认成功") {
                                            table.reload('LAY-reservation-list');
                                            layer.msg(res.msg);
                                            layer.close(index);
                                        }
                                    }

                                });
                            });
                            submit.trigger('click');
                        }
                    });
                    break;
                case "cancel":
                    admin.req({
                        url: setter.host + `/reservation/receiveManager/cancelReservation`
                        , type: 'post'
                        , data: {"reservationNumber": data.reservationNumber}
                        , done: function (res) {
                            if (res.code === 0 && res.msg === "预约取消成功") {
                                table.reload('LAY-reservation-list');
                                layer.msg(res.msg);
                            }
                        }
                    });
                    break;
                case "chidao":
                    layer.open({
                        type: 2
                        , title: '迟到重新分配'
                        , content: setter.host + '/chidao'
                        , area: ['720px', '590px']
                        , btn: ['重新分配', '取消']
                        , success: function (editFrame, index) {
                            var iframeWindow = window['layui-layer-iframe' + index]
                                , subBody = editFrame.find('iframe').contents();
                            console.log("一行数据", data)
                            let timeoutCount = 0
                            for (let item of data.drivers) {
                                if (item.timeoutStatus == 2) {
                                    timeoutCount++
                                    subBody.find("#cars").append(`
                                        <label class="layui-form-label">车辆信息：</label>
                                        <input type="hidden" name="carId[]" value="${item.id}" >

                                        <div class="layui-form-item">
                                          <label class="layui-form-label">车型</label>
                                          <div class="layui-input-inline" >
                                            <input type="text"  value="${item.carType}" id="carType" readonly autocomplete="off" class="layui-input">
                                          </div>
                                       </div>
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">车长</label>
                                          <div class="layui-input-inline" >
                                            <input type="text"  value="${item.carLength}" id="carLength" readonly autocomplete="off" class="layui-input">
                                          </div>
                                        </div>
                                    
                                    
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">分配月台</label>
                                          <div class="layui-input-inline" >
                                            <input type="hidden" name="estimatedPlatformNumber"  id="estimatedPlatformNumber" readonly autocomplete="off" class="layui-input">
                                            <select name="confirmPlatformNumber[]" id="platform" lay-verify="required"  >
                                              <option value="${item.carLength}" >${item.acPlatform.platformCode}</option>
                                            </select>
                                          </div>
                                        </div>
                                    
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">分配收货员</label>
                                          <div class="layui-input-inline" >
                                            <input type="hidden" name="estimatedReceiverNumber" id="estimatedReceiverNumber"  autocomplete="off" class="layui-input" >
                                            <select name="confirmReceiverNumber[]" id="receiver" lay-verify="required">
                                                <option value="${item.Receiver}" >${item.acReceiver.receiverName}</option>
                                            </select>
                                          </div>
                                        </div>
                                        `)
                                }

                            }

                            subBody.find("#id").val(data.id)
                            subBody.find("#driverCount").val(timeoutCount)
                            subBody.find("#reservationNumber").val(data.reservationNumber)
                            subBody.find("#driverNumber").val(data.driverNumber)
                            subBody.find("#supplierNumber").val(data.supplierNumber)
                            subBody.find("#supplierName").val(data.supplierName)
                            subBody.find("#gdsCount").val(Number(data.gdsCount))
                            subBody.find("#gdsNumber").val(Number(data.gdsNumber))
                            subBody.find("#confirmArrivalTime").val(data.confirmArrivalTime)
                            subBody.find("#durationTime").val(Number(data.confirmOverTime))
                            subBody.find("#trayCount").val(data.trayCount)


                        }
                        //提交修改月台和收货员信息的url
                        , yes: function (index, layero) {
                            var iframeWindow = window['layui-layer-iframe' + index]
                                , submitID = 'LAY-menu-edit-submit'
                                , submit = layero.find('iframe').contents().find('#' + submitID);
                            //监听提交
                            iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                                let playload = data.field
                                console.log(playload)
                                $.ajax({
                                    url: setter.host + `/reservation/receiveManager/changePlatform`
                                    , type: "POST"
                                    , data: JSON.stringify(playload)
                                    , contentType: "application/json; charset=utf-8"
                                    , dataType: "json"
                                    , success: function (res) {
                                        if (res.code === 0 && res.msg === "重新分配月台成功") {
                                            table.reload('LAY-reservation-list');
                                            layer.msg(res.msg);
                                            layer.close(index);
                                        }
                                    }
                                })
                            });
                            submit.trigger('click');
                        }
                    });
                    break
                case "zaodao":
                    layer.open({
                        type: 2
                        , title: '早到'
                        , content: setter.host + '/confirm'
                        , area: ['720px', '590px']
                        , btn: ['确定', '取消']
                        , success: function (editFrame, index) {
                            var iframeWindow = window['layui-layer-iframe' + index]
                                , subBody = editFrame.find('iframe').contents();
                            subBody.find("#id").val(data.id)
                            subBody.find("#reservationNumber").val(data.reservationNumber)
                            subBody.find("#driverNumber").val(data.driverNumber)
                            subBody.find("#supplierNumber").val(data.supplierNumber)
                            subBody.find("#orderNumber").val(data.orderNumber)
                            subBody.find("#confirmArrivalTime").val(data.estimatedTimeOfArrival)
                        }
                        //提交修改月台和收货员信息的url
                        , yes: function (index, layero) {
                            var iframeWindow = window['layui-layer-iframe' + index]
                                , submitID = 'LAY-menu-edit-submit'
                                , submit = layero.find('iframe').contents().find('#' + submitID);
                            //监听提交
                            iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                                let playload = data.field
                                console.log(playload)
                                admin.req({
                                    url: setter.host + `/reservation/receiveManager/changePlatform`
                                    , type: 'post'
                                    , header: {"Content-Type": "application/x-www-form-urlencoded"}
                                    , dataType: 'json'
                                    , contentType: "application/json; charset=utf-8"
                                    , data: JSON.stringify(playload)
                                    , done: function (res) {
                                        if (res.code === 0 && res.msg === "预约单确认成功") {
                                            table.reload('LAY-reservation-list');
                                            layer.msg(res.msg);
                                            layer.close(index);
                                        }
                                    }

                                });
                            });
                            submit.trigger('click');
                        }
                    });
                    break
                case "checkPlatform":
                    layer.open({
                        type: 1
                        ,
                        title: '月台详情'
                        ,
                        content: '<div class="layui-container" style="width: 98%"><table id="LAY-human-gzjl" lay-filter="LAY-human-gzjl" class=""></table></div>'
                        ,
                        shadeClose: true//开启遮罩关闭
                        ,
                        area: ['70%', '90%']
                        ,
                        maxmin: true
                        ,
                        btn: ['确定']
                        ,
                        success: function (layero, index) {
                            table.render({
                                elem: '#LAY-human-gzjl'  // 弹出层表格id
                                , url: setter.host + '/human/menu/getGongzuo' // 后端请求URL地址
                                , method: 'post'
                                , where: {'platformNumber': data.id}
                                , page: true
                                , contentType: "application/json; charset=utf-8"
                                , cols: [[
                                    {field: 'platformNumber', title: '月台编号', sort: true, align: 'center', hide: true},
                                    {field: 'platformCode', title: '月台号', sort: true, align: 'center'},
                                    {
                                        field: 'platformIsUse',
                                        title: '是否正在使用',
                                        sort: true,
                                        align: 'center',
                                        width: 100,
                                        sort: true,
                                        templet: function (d) {
                                            if (d.platformIsUse == 0) {
                                                return '未使用'
                                            } else if (d.platformIsUse == 1) {
                                                return '正在使用'
                                            }
                                        }
                                    },
                                ]]
                            })
                        }
                        ,
                        yes: function (index, layero) {
                            layer.close(index)
                        }
                    });
                    break;
                case "checkReceiver":
                    layer.open({
                        type: 1
                        ,
                        title: '售货员详情'
                        ,
                        content: '<div class="layui-container" style="width: 98%"><table id="LAY-human-gzjl" lay-filter="LAY-human-gzjl" class=""></table></div>'
                        ,
                        shadeClose: true//开启遮罩关闭
                        ,
                        area: ['70%', '90%']
                        ,
                        maxmin: true
                        ,
                        btn: ['确定']
                        ,
                        success: function (layero, index) {
                            table.render({
                                elem: '#LAY-human-gzjl'  // 弹出层表格id
                                , url: setter.host + '/human/menu/getGongzuo' // 后端请求URL地址
                                , method: 'post'
                                , where: {'headField': 'gz_start,gz_over,gz_bumen,gz_gangwei', 'user_id': data.id}
                                , page: true
                                , contentType: "application/json; charset=utf-8"
                                , cols: [[
                                    {field: 'gz_start', title: '开始日期', sort: true, align: 'center'},
                                    {field: 'gz_over', title: '结束日期', sort: true, align: 'center'},
                                    {
                                        field: 'gz_bumen',
                                        title: '部门',
                                        sort: true,
                                        align: 'center',
                                        width: 100,
                                        sort: true,
                                    },
                                    {
                                        field: 'gz_gangwei',
                                        title: '岗位',
                                        align: 'center',
                                        sort: true,
                                        sort: true,
                                        width: 130,
                                    },
                                ]]
                            })
                        }
                        ,
                        yes: function (index, layero) {
                            layer.close(index)
                        }
                    });
                    break;
                case "checkDriver":
                    layer.open({
                        type: 1
                        ,
                        title: '司机详情'
                        ,
                        content: '<div class="layui-container" style="width: 98%"><table id="LAY-human-gzjl" lay-filter="LAY-human-gzjl" class=""></table></div>'
                        ,
                        shadeClose: true//开启遮罩关闭
                        ,
                        area: ['70%', '90%']
                        ,
                        maxmin: true
                        ,
                        btn: ['确定']
                        ,
                        success: function (layero, index) {
                            table.render({
                                elem: '#LAY-human-gzjl'  // 弹出层表格id
                                , url: setter.host + '/human/menu/getGongzuo' // 后端请求URL地址
                                , method: 'post'
                                , where: {'headField': 'gz_start,gz_over,gz_bumen,gz_gangwei', 'user_id': data.id}
                                , page: true
                                , contentType: "application/json; charset=utf-8"
                                , cols: [[
                                    {field: 'gz_start', title: '开始日期', sort: true, align: 'center'},
                                    {field: 'gz_over', title: '结束日期', sort: true, align: 'center'},
                                    {
                                        field: 'gz_bumen',
                                        title: '部门',
                                        sort: true,
                                        align: 'center',
                                        width: 100,
                                        sort: true,
                                    },
                                    {
                                        field: 'gz_gangwei',
                                        title: '岗位',
                                        align: 'center',
                                        sort: true,
                                        sort: true,
                                        width: 130,
                                    },
                                ]]
                            })
                        }
                        ,
                        yes: function (index, layero) {
                            layer.close(index)
                        }
                    });
                    break;
                case "reallocation":
                    layer.open({
                        type: 2
                        , title: '收货员及月台重新分配'
                        , content: setter.host + '/reallocation'
                        , area: ['720px', '590px']
                        , btn: ['重新分配', '取消']
                        , success: function (editFrame, index) {
                            var iframeWindow = window['layui-layer-iframe' + index]
                                , subBody = editFrame.find('iframe').contents();
                            console.log("一行数据", data)
                            let timeoutCount = 0
                            for (let item of data.drivers) {
                                if (item.nowStatus > 2 && item.nowStatus < 5) {
                                    timeoutCount++
                                    subBody.find("#cars").append(`
                                        <label class="layui-form-label">车辆信息：</label>
                                        <input type="hidden" name="carId[]" value="${item.id}" >

                                        <div class="layui-form-item">
                                          <label class="layui-form-label">车型</label>
                                          <div class="layui-input-inline" >
                                            <input type="text"  value="${item.carType}" id="carType" readonly autocomplete="off" class="layui-input">
                                          </div>
                                       </div>
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">车长</label>
                                          <div class="layui-input-inline" >
                                            <input type="text"  value="${item.carLength}" id="carLength" readonly autocomplete="off" class="layui-input">
                                          </div>
                                        </div>
                                    
                                    
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">分配月台</label>
                                          <div class="layui-input-inline" >
                                            <input type="hidden" name="estimatedPlatformNumber"  id="estimatedPlatformNumber" readonly autocomplete="off" class="layui-input">
                                            <select name="confirmPlatformNumber[]" id="platform" lay-verify="required"  >
                                              <option value="${item.carLength}" >${item.acPlatform.platformCode}</option>
                                            </select>
                                          </div>
                                        </div>
                                    
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">分配收货员</label>
                                          <div class="layui-input-inline" >
                                            <input type="hidden" name="estimatedReceiverNumber" id="estimatedReceiverNumber"  autocomplete="off" class="layui-input" >
                                            <select name="confirmReceiverNumber[]" id="receiver" lay-verify="required">
                                                <option value="${item.Receiver}" >${item.acReceiver.receiverName}</option>
                                            </select>
                                          </div>
                                        </div>
                                        `)
                                } else {
                                    subBody.find("#cars").append(`<label class="layui-form-label">当前状态无法重新分配</label>`)
                                }

                            }

                            subBody.find("#id").val(data.id)
                            subBody.find("#driverCount").val(timeoutCount)
                            subBody.find("#reservationNumber").val(data.reservationNumber)
                            subBody.find("#driverNumber").val(data.driverNumber)
                            subBody.find("#supplierNumber").val(data.supplierNumber)
                            subBody.find("#supplierName").val(data.supplierName)
                            subBody.find("#gdsCount").val(Number(data.gdsCount))
                            subBody.find("#gdsNumber").val(Number(data.gdsNumber))
                            subBody.find("#confirmArrivalTime").val(data.confirmArrivalTime)
                            subBody.find("#durationTime").val(Number(data.confirmOverTime))
                            subBody.find("#trayCount").val(data.trayCount)


                        }
                        //提交修改月台和收货员信息的url
                        , yes: function (index, layero) {
                            var iframeWindow = window['layui-layer-iframe' + index]
                                , submitID = 'LAY-menu-edit-submit'
                                , submit = layero.find('iframe').contents().find('#' + submitID);
                            //监听提交
                            iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                                let playload = data.field
                                console.log(playload)
                                $.ajax({
                                    url: setter.host + `/reservation/receiveManager/changePlatform`
                                    , type: "POST"
                                    , data: JSON.stringify(playload)
                                    , contentType: "application/json; charset=utf-8"
                                    , dataType: "json"
                                    , success: function (res) {
                                        if (res.code === 0 && res.msg === "重新分配月台成功") {
                                            table.reload('LAY-reservation-list');
                                            layer.msg(res.msg);
                                            layer.close(index);
                                        }
                                    }
                                })
                            });
                            submit.trigger('click');
                        }
                    });
                    break
                case "details":
                    layer.open({
                        type: 2
                        , title: '预约详情'
                        , content: setter.host + '/details'
                        , area: ['720px', '590px']
                        , btn: ['关闭']
                        , success: function (editFrame, index) {
                            var iframeWindow = window['layui-layer-iframe' + index]
                                , subBody = editFrame.find('iframe').contents();
                            console.log("一行数据", data)
                            let timeoutCount = 0
                            for (let item of data.drivers) {
                                timeoutCount++
                                subBody.find("#cars").append(`
                                        <label class="layui-form-label">车辆信息：</label>
                                        <input type="hidden" name="carId[]" value="${item.id}" >

                                        <div class="layui-form-item">
                                          <label class="layui-form-label">车型</label>
                                          <div class="layui-input-inline" >
                                            <input type="text"  value="${item.carType}" id="carType" readonly autocomplete="off" class="layui-input">
                                          </div>
                                       </div>
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">车长</label>
                                          <div class="layui-input-inline" >
                                            <input type="text"  value="${item.carLength}" id="carLength" readonly autocomplete="off" class="layui-input">
                                          </div>
                                        </div>
                                    
                                    
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">分配月台</label>
                                          <div class="layui-input-inline" >
                                            <input type="text"  value="${item.acPlatform.platformCode}" id="carLength" readonly autocomplete="off" class="layui-input">
                                          </div>
                                        </div>
                                    
                                        <div class="layui-form-item">
                                          <label class="layui-form-label">分配收货员</label>
                                          <div class="layui-input-inline" >
                                          <input type="text"  value="${item.acReceiver.receiverName}" id="carLength" readonly autocomplete="off" class="layui-input">
                                          </div>
                                        </div>
                                        `)

                            }

                            subBody.find("#id").val(data.id)
                            subBody.find("#driverCount").val(timeoutCount)
                            subBody.find("#reservationNumber").val(data.reservationNumber)
                            subBody.find("#driverNumber").val(data.driverNumber)
                            subBody.find("#supplierNumber").val(data.supplierNumber)
                            subBody.find("#supplierName").val(data.supplierName)
                            subBody.find("#gdsCount").val(Number(data.gdsCount))
                            subBody.find("#gdsNumber").val(Number(data.gdsNumber))
                            subBody.find("#confirmArrivalTime").val(data.confirmArrivalTime)
                            subBody.find("#durationTime").val(Number(data.confirmOverTime))
                            subBody.find("#trayCount").val(data.trayCount)


                        }
                        //提交修改月台和收货员信息的url
                        // ,yes: function(index, layero){
                        //     var iframeWindow = window['layui-layer-iframe'+ index]
                        //         ,submitID = 'LAY-menu-edit-submit'
                        //         ,submit = layero.find('iframe').contents().find('#'+ submitID);
                        //     //监听提交
                        //     iframeWindow.layui.form.on('submit('+ submitID +')', function(data){
                        //         let playload=data.field
                        //         console.log(playload)
                        //         $.ajax({
                        //             url:setter.host+`/reservation/receiveManager/changePlatform`
                        //             ,type:"POST"
                        //             ,data:JSON.stringify(playload)
                        //             ,contentType:"application/json; charset=utf-8"
                        //             ,dataType:"json"
                        //             ,success:function (res){
                        //                 if(res.code === 0 && res.msg==="重新分配月台成功"){
                        //                     table.reload('LAY-reservation-list');
                        //                     layer.msg(res.msg);
                        //                     layer.close(index);
                        //                 }
                        //             }
                        //         })
                        //     });
                        //     submit.trigger('click');
                        // }
                    });
                    break
            }

            console.log(obj)

        });
    }

    $('.layui-btn').on('click', function () {
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });


    var active = {
        batchdel: function () {
            var checkData = renderTable.checkStatus()
            if (checkData.length === 0) {
                return layer.msg('请选择数据');
            }
            layer.prompt({
                formType: 1
                , title: '敏感操作，请验证当前用户口令'
            }, function (value, index_prompt) {
                var command = layui.sessionData('layuiSession').command;
                if (value == command) {
                    layer.close(index_prompt);
                    layer.confirm('确定删除吗？', function (index_confirm) {
                        layer.close(index_confirm);
                        //因为是单选项，只能选择一个
                        if (checkData[0].hasOwnProperty('children')) {
                            layer.confirm('该选择的删除数据有子菜单,确定都删除吗?', {icon: 3, title: '提示'}, function (index_del) {
                                layer.close(index_del);
                                del(checkData[0].menuId, checkData[0].pId);
                            });
                        } else {
                            del(checkData[0].menuId, checkData[0].pId);
                        }
                    });
                } else {
                    layer.msg('口令错误');
                }
            });
        }
        , add: function () {
            var obj = {};
            obj.bakUrl = setter.host + '/human/menu/toMenuList';
            obj.jsType = 'add';
            layui.common.postUrl(obj, setter.host + '/human/menu/toInsert');
        }
        , edit: function () {
            var checkData = renderTable.checkStatus();
            if (checkData.length > 1) {
                return layer.msg('只能选中编辑一行');
            }
            if (checkData.length === 0) {
                return layer.msg('请选择一行数据进行编辑');
            }
            layer.open({
                type: 2
                , title: '编辑菜单'
                , content: setter.host + '/human/menu/toEdit'
                , area: ['720px', '590px']
                , btn: ['确定', '取消']
                , success: function (editFrame, index) {
                    var iframeWindow = window['layui-layer-iframe' + index]
                        , subBody = editFrame.find('iframe').contents();
                    var type = checkData[0].type;
                    subBody.find("#id").val(checkData[0].id)
                }
                , yes: function (index, layero) {
                    var iframeWindow = window['layui-layer-iframe' + index]
                        , submitID = 'LAY-menu-edit-submit'
                        , submit = layero.find('iframe').contents().find('#' + submitID);
                    //监听提交

                    console.log(iframeWindow, submitID, submit)
                    iframeWindow.layui.form.on('submit(' + submitID + ')', function (data) {
                        console.log(JSON.stringify(data.field))
                        admin.req({
                            url: setter.host + '/human/menu/upUser'
                            , type: 'post'
                            , dataType: 'json'
                            , contentType: "application/json; charset=utf-8"
                            , data: JSON.stringify(data.field)
                            , done: function (res) {
                                //请求成功后
                                if (res.status == setter.response.statusCode.status_Success) {
                                    if (data.field.pId == '-1' || data.field.toChangePid == '-1') {
                                        loadTable(colsArr, field);
                                    } else {
                                        renderTable.refresh(data.field.pId);
                                        //如果更新的菜单与当前修改的父菜单不一样，那么还需要刷新新修改后的菜单
                                        if (data.field.toChangePid != '' && data.field.pId != data.field.toChangePid) {
                                            renderTable.refresh(data.field.toChangePid);
                                        }
                                    }
                                }
                                layer.close(index);
                                layer.msg(res.msg);
                            }
                        });
                    });
                    submit.trigger('click');
                }
            });
        }
    }

    function del(menuId, pId) {
        var indexLoad = layer.msg('删除菜单，请稍后', {
            icon: 16
            , shade: 0.01
        });
        admin.req({
            url: setter.host + '/adminmanager/menu/batchdelMenu'
            , type: 'post'
            , contentType: "application/json; charset=utf-8"
            , data: '{"menuId":"' + menuId + '","pId":"' + pId + '"}'
            , done: function (res) {
                //请求成功后
                if (res.status == setter.response.statusCode.status_Success) {
                    if (pId == '-1') {
                        loadTable(colsArr, field);
                    } else {
                        renderTable.refresh(pId);
                    }
                }
                layer.close(indexLoad);
                layer.msg(res.msg);
            }
        });
    }

    form.on('submit(LAY-human-normal-search)', function (data) {
        let search = {};

        search.key = data.field.whereKey;
        search.value = data.field.whereValue;

        console.log(data)
        renderTable.reload({
            url: setter.host + `/reservation/receiveManager/filterTable`,
            method: "post",
            where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                search: search //查询字段
            }
        });
    });

    //对外暴露的接口
    exports('holiday', {});
});